const tree = {
    id: 1,
    children: [
        {
            id: 2,
            children: [
                {
                    id: 3,
                    children: [
                        {
                            id: 4,
                            children: [],
                        },
                    ],
                },
                {
                    id: 5,
                    children: [],
                },
            ],
        },
        {
            id: 6,
            children: [],
        },
    ],
};


function BFS(node){
    if(!node){
        return 
    }
    let queue = [node]
    while(queue.length){
        let node = queue.shift()
        console.log(node.id)
        for (const child of node.children) {
            queue.push(child)
        }
    }
}

BFS(tree)
console.log('------------------')
function DFS(root){
    if(!root){
        return
    }
    console.log(root.id)
    for (const child of root.children) {
        DFS(child)
    }

}
DFS(tree)